from django.shortcuts import render
from home import models, homeser
from rest_framework.views import APIView
from rest_framework.response import Response
# Create your views here.


class NavView(APIView):
    def get(self, request):
        pos = request.query_params.get('pos')
        navlist = models.Nav.objects.filter(position=pos, is_show=True).order_by("order")
        ser = homeser.NavSer(navlist, many=True)
        return Response({'msg': 'ok', 'data': ser.data})


class BannerView(APIView):
    def get(self, request):
        bannerlist = models.Banner.objects.filter(is_show=True).order_by("order")
        ser = homeser.BannerSer(bannerlist, many=True)
        return Response({'msg': 'ok', 'data': ser.data})
